#include<iostream>
#include<vector>
#include<cstring>
#define ONLINE_JUDGE
#define ll long long
#define ull unsigned long long
using namespace std;

const int N = 1e4 + 10, INF = 0x3f3f3f3f;

int n, m;
vector<int> g[N], rg[N], s;
int scc[N], vis[N], cnt;

void dfs1(int x)
{
    if (vis[x] != 0) return;
    vis[x] = 1;
    for (int y : g[x]) dfs1(y);
    s.push_back(x);
}

void dfs2(int x)
{
    if (scc[x] != 0) return;
    scc[x] = cnt;
    for (int y : rg[x]) dfs2(y);
}

void Kosaraju() {
    cnt = 0;
    s.clear();
    memset(vis, 0, sizeof vis);
    memset(scc, 0, sizeof scc);
    for (int i = 1;i <= n;i++)  dfs1(i);
    for (int i = n - 1;i >= 0;i--)
        if (scc[s[i]] == 0) {
            cnt++;
            dfs2(s[i]);
        }
}

void solve()
{
    while (cin >> n >> m) {
        if (n == 0 && m == 0) break;
        for (int i = 1;i <= n;i++) { g[i].clear(), rg[i].clear(); }
        for (int i = 1, x, y;i <= m;i++) {
            cin >> x >> y;
            g[x].push_back(y);
            rg[y].push_back(x);
        }
        Kosaraju();
        if (cnt == 1) cout << "Yes\n";
        else cout << "No\n";
    }
}

signed main()
{
    // ios::sync_with_stdio(0);
    // cin.tie(0);cout.tie(0);
#ifndef ONLINE_JUDGE
    std::istringstream in(R"()");
    std::cin.rdbuf(in.rdbuf());
#endif
    int T = 1;
    //cin>>T;
    for (int i = 1;i <= T;i++) {
        solve();
    }
}

